import{hexMD5 } from './md5'

let signature = {}

signature.appkey = '123456'
signature.secret = 'ABCDEF'
signature.signal = (timestamp,nonce) =>{
  let keyvalues = {
    "appkey":signature.appkey,
    "timestamp":timestamp,
    "nonce":nonce
  }
  var signkeys=Object.keys(keyvalues).sort()
  let signstr = signature.secret
  for(let x in signkeys){
    signstr += signkeys[x] + keyvalues[signkeys[x]]
  }
  return hexMD5(signstr)
}
signature.createurl = (timestamp,nonce,signaturevalue) =>{
   let paramurl = '?timestamp=' + timestamp + '&nonce=' + nonce + '&appkey=' + signature.appkey + '&signature=' + signaturevalue
   return paramurl
}
export default signature